package ar.com.temporis.util.bean;

import java.lang.reflect.InvocationTargetException;

// REFACTORME: emprolijar el manejo de exceptions
public class BeanUtils {

	/* Creo que tengo que usar BeanUtilsBean.getInstance().getPropertyUtils().getProperty(bean, name);
	 * este retorna Object y no String
	 */
	public static String getProperty(Object object, String property) {
		try {
			return org.apache.commons.beanutils.BeanUtils.getProperty(object, property);
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public static void set(Object bean, String key, Object object) {
		try {
			org.apache.commons.beanutils.BeanUtils.setProperty(bean, key, object);
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	
}
